using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ManagementClinic.Data.Models.Mapping
{
    public class KHACH_HANGMap : EntityTypeConfiguration<KHACH_HANG>
    {
        public KHACH_HANGMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.TEN)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.DAN_TOC)
                .HasMaxLength(50);

            this.Property(t => t.DIA_CHI)
                .HasMaxLength(50);

            this.Property(t => t.DIEN_THOAI)
                .HasMaxLength(50);

            this.Property(t => t.TIEN_SU_BENH)
                .HasMaxLength(500);

            this.Property(t => t.GHI_CHU)
                .HasMaxLength(100);

            this.Property(t => t.MODIFY_USER)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("KHACH_HANG");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.TEN).HasColumnName("TEN");
            this.Property(t => t.NGAY_SINH).HasColumnName("NGAY_SINH");
            this.Property(t => t.GIOI_TINH).HasColumnName("GIOI_TINH");
            this.Property(t => t.DAN_TOC).HasColumnName("DAN_TOC");
            this.Property(t => t.DIA_CHI).HasColumnName("DIA_CHI");
            this.Property(t => t.ID_TINH_THANH).HasColumnName("ID_TINH_THANH");
            this.Property(t => t.DIEN_THOAI).HasColumnName("DIEN_THOAI");
            this.Property(t => t.TIEN_SU_BENH).HasColumnName("TIEN_SU_BENH");
            this.Property(t => t.GHI_CHU).HasColumnName("GHI_CHU");
            this.Property(t => t.MODIFY_USER).HasColumnName("MODIFY_USER");
            this.Property(t => t.MODIFY_DATE).HasColumnName("MODIFY_DATE");

            // Relationships
            this.HasOptional(t => t.TINH_THANH)
                .WithMany(t => t.KHACH_HANG)
                .HasForeignKey(d => d.ID_TINH_THANH);

        }
    }
}
